@extends('layouts.admin')
@section('css')
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_page.css') }}" rel="stylesheet" />
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_table.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-datepicker/css/datepicker.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker-bs3.css') }}" rel="stylesheet">
@endsection
@section('content')
<section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <!-- <div class="col-sm-12">
                      <section class="panel">
                          
                          <div class="panel-body">
                                   
                          </div>
                      </section>
                  </div> -->
                  <div class="col-lg-12">
                      <section class="panel">
                        <div class="panel-body">
                      
                          <header class="panel-heading">
                              【<font color=red>{{ $group->name }}</font>】数据统计
                          </header>
                          <div class="panel-body">
                                <div class="adv-table">
                      
                              <div class="panel-body left col-lg-6"  align="left">
                              @if (count($errors) > 0)
                                <div class="alert alert-block alert-danger fade in">
                                  <button data-dismiss="alert" class="close close-sm" type="button">
                                      <i class="icon-remove"></i>
                                  </button>
                                  <!-- <strong>Oh snap!</strong> Change a few things up and try submitting again. -->
                                   <ul>
                                        @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li> 
                                        @endforeach
                                    </ul>
                              </div>
                              @endif
                             <form class="form-inline" method="POST" action="{{ route('admin.statistics.groups.agents.add') }}" role="form" >
                                  {{ csrf_field() }}
                                  <div class="form-group">
                                      <label class="sr-only" for="exampleInputPassword2">电话</label>
                                      <input type="hidden" class="form-control" id="id" name="id" value="{{ $id }}">
                                      <input type="text" class="form-control" id="mobile" name="mobile" value="" placeholder="输入经纪人手机">
                                  </div>
                                  <button type="submit" class="btn btn-success">添加组员</button>
                              </form>

                          </div>
                          <div class="panel-body right col-lg-6"  align="right">          
                            <form class="form-inline" action="{{ route('admin.statistics.groups.agents',['id'=>$id]) }}" role="form" method="get">
                                  {{ csrf_field() }}
                                  
                                  
                                  <div class="form-group "  >
                                        <input type="text" class="form-control dpd1 default-date-picker" name="from" value="{{ $data['from'] }}" placeholder="开始日期">
                                  </div>
                                  -
                                  <div class="form-group "  >
                                            <input type="text" class="form-control dpd2 default-date-picker" name="to" value="{{ $data['to'] }}" placeholder="截止日期">
                                  </div>
                                  <button type="submit" class="btn btn-info">搜索</button>
                              </form>

                    </div>
                                    <table  class="display table table-bordered table-striped" id="reply">
                                      <thead>
                                      <tr>                                                                                   
                                          <th>经纪人名称</th>
                                          <th>推广人数</th>
                                          <th>客户订单数</th>
                                          <th>客户综合交易费</th>
                                          <th>创造收入</th>
                                          <th>客户入金</th>
                                          <th>客户提现</th>
                                          <th>客户余额</th>                                          
                                          <th class="hidden-phone"></th>
                                      </tr>
                                      </thead>
                                      <tbody>
                                      @foreach($records as $r)
                                      <tr class="gradeX">
                                                                                   
                                          <td>{{ $r->user->name }}({{ $r->user->mobile }})</td>
                                          <td>{{ $r->user_count }}</td>
                                          <td>{{ $r->orders_count }}</td>
                                          <td>{{ $r->total_cost }}</td>
                                          <td>{{ $r->total_profit }}</td>
                                          <td>{{ $r->total_rechages }}</td>
                                          <td>{{ $r->total_withdrawals }}</td>
                                           <td>{{ $r->user->children()->sum('balance') }}</td>                                   
                                          <td class="center hidden-phone">
                                            
                                            <a href="{{ route('admin.statistics.groups.agents.users',['id'=>$r->id]) }}"
                                               class="btn btn-primary btn-xs"><i class="icon-user"></i> </a>

                                            <a href="{{ route('admin.statistics.groups.agents.orders',['id'=>$r->id]) }}"
                                               class="btn btn-primary btn-xs"><i class="icon-shopping-cart"></i> </a>
                                            
                                            <a class="btn btn-danger btn-xs user-delete"
                                               data-href="{{ route('admin.statistics.groups.agents.destroy',['id'=>$r->id]) }}">
                                                <i class="icon-trash"></i> </a>
                                          </td>
                                      </tr>
                                      @endforeach
                                      
                                
                                      <tfoot>
                                      
                                      </tfoot>
                          </table>
                                </div>
                          </div>
                          </div>
                      </section>
                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
@endsection
@section('javascript')
<script type="text/javascript" language="javascript" src="{{ asset('admin/assets/advanced-datatable/media/js/jquery.dataTables.js') }}"></script>
 <script type="text/javascript" src="{{ asset('admin/assets/bootstrap-datepicker/js/bootstrap-datepicker.js') }}"></script>
<script type="text/javascript" src="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker.js') }}"></script>

<script src="{{ asset('admin/js/advanced-form-components.js') }}"></script>
 <script type="text/javascript" charset="utf-8">
      $(document).ready(function() {
          $('#reply').dataTable( {
              "aaSorting": [[ 4, "desc" ]],
              "oLanguage": {
                   "oPaginate": {
                     "sLast": "最后一页",
                     "sNext":"下页",
                     "sPrevious":"上页",
                     "sEmptyTable":"表里没有数据",
                   },
                   "sInfo": " _START_ - _END_ / _TOTAL_ 条记录",
                   "sLengthMenu": "显示 _MENU_ 条记录",
                   "sSearch": "搜索:",
                 }
          } );
      } );


        $(".user-delete").click(function () {
            Rbac.ajax.delete({
                type:'delete',
                data:{"_token" : "{{ csrf_token() }}" },
                confirmTitle: '确定删除该经纪人吗?',
                href: $(this).data('href'),
                successTitle: '删除成功'
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                confirmTitle: '确定删除选中的期权?',
                href: $(this).data('href'),
                successTitle: '删除成功'
            });
        });
    
      
  </script>  
@endsection

